package com.fita.entity.data;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "exchange_rate")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class ExchangeRate {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 汇率 */
    private BigDecimal rate;
    
    /** 货币代码 */
    private String currencyCode;
    
    /** 货币符号 */
    private String currencySymbol;
    
    /** 货币名称 */
    private String currencyName;
    
    /** 汇率生效时间 */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date effectiveTime;
    
    private Long operator;
    
    private Date createTime;
    
    /**
     * 
     */
    public ExchangeRate() {
        
    }

    /**
     * @param id
     * @return
     */
    public ExchangeRate initliaze(Long id) {
        this.createTime = new Date();
        this.operator = id;
        return this;
    }


    /**
     * 初始化
     * @param exchangeRate
     * @param rate
     * @return
     */
    public ExchangeRate create(ExchangeRate exchangeRate, BigDecimal rate, Long operator) {

        this.createTime = new Date();
        this.effectiveTime = new Date();
        this.rate = rate;
        this.currencyCode = exchangeRate.getCurrencyCode().trim();
        this.currencyName = exchangeRate.getCurrencyName().trim();
        this.currencySymbol = exchangeRate.getCurrencySymbol().trim();
        this.operator = operator;

        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the rate
     */
    public BigDecimal getRate() {
        return rate;
    }

    /**
     * @return the currencyCode
     */
    public String getCurrencyCode() {
        return currencyCode;
    }

    /**
     * @return the currencySymbol
     */
    public String getCurrencySymbol() {
        return currencySymbol;
    }

    /**
     * @return the currencyName
     */
    public String getCurrencyName() {
        return currencyName;
    }

    /**
     * @return the effectiveTime
     */
    public Date getEffectiveTime() {
        return effectiveTime;
    }

    /**
     * @return the operator
     */
    public Long getOperator() {
        return operator;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param rate the rate to set
     */
    public void setRate(BigDecimal rate) {
        this.rate = rate;
    }

    /**
     * @param currencyCode the currencyCode to set
     */
    public void setCurrencyCode(String currencyCode) {
        this.currencyCode = currencyCode;
    }

    /**
     * @param currencySymbol the currencySymbol to set
     */
    public void setCurrencySymbol(String currencySymbol) {
        this.currencySymbol = currencySymbol;
    }

    /**
     * @param currencyName the currencyName to set
     */
    public void setCurrencyName(String currencyName) {
        this.currencyName = currencyName;
    }

    /**
     * @param effectiveTime the effectiveTime to set
     */
    public void setEffectiveTime(Date effectiveTime) {
        this.effectiveTime = effectiveTime;
    }

    /**
     * @param operator the operator to set
     */
    public void setOperator(Long operator) {
        this.operator = operator;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

}
